package main

import gui._
import java.awt.Dimension
import javax.imageio.ImageIO
import javax.swing.WindowConstants
import lang.LOC
import scala.swing.Dialog
import scala.swing.MainFrame

/**
 * Die Main-Klasse des Programms. Zustaendig fuer das Erzeugen des MainFrames
 * der Benutzeroberflaeche.
 */

object Main {
  def main(args: Array[String]) {
    var l = new Layout()

    val mainWindow = new MainFrame() {
      peer.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE)

      title = LOC.get("Titel")
      iconImage = ImageIO.read(this.getClass().getResource("/gui/img/icon_16.png"))
      minimumSize = new Dimension(696, 480) // TODO wieder ändern
      menuBar = l.menuBar
      contents = l.layout
      visible = true
      maximize

      override def closeOperation() { showCloseDialog() }

      private def showCloseDialog() {
        if(l.hasNonsavedProjects()) {
          Dialog.showConfirmation(parent = null,         
                                title = LOC.get("WirklichBeendenTitle"),         
                                message = LOC.get("WirklichBeendenText")       
          ) match {
            case Dialog.Result.Ok => System.exit(0)        
            case _ => ()       
          }
        }
        else
          System.exit(0)

      } 
    }
  }
  
}


 